<template>
  <DynamicForm :formItems="formItems" :data="formData"/>
</template>

<script setup>
import DynamicForm from '@/components/DynamicForm.vue'
import { ref } from 'vue'

const formItems = ref([
  {
    label: '名称',
    type: 'input',
    field: 'name',
    validator: [{ required: true, message: 'name is required', trigger: 'blur' },],
  },
  {
    label: '性别',
    type: 'select',
    field: 'sex',
    options: [
      { value: 1, label: '男'},
      { value: 2, label: '女'},
    ],
  },
  {
    label: '客户',
    type: 'select',
    field: 'userId',
    options: [
      { value: 201, label: '张三'},
      { value: 202, label: '李四'},
    ],
    dependence: { field: 'sex', value: 1 },
  },
])

const formData = ref({
  name: '',
  sex: '',
  userId: '',
})
</script>

<style>
</style>
